from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QComboBox, QCheckBox, QPushButton


class BaseSettingsWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.initUI()

    def change_correct_system_time_checkbox(self):
        if self.correct_time_checkbox.isChecked():
            self.save_button.setEnabled(True)
        else:
            self.save_button.setDisabled(True)

    def initUI(self):
        layout = QVBoxLayout()
        self.setLayout(layout)
        layout.addWidget(QLabel('Регион'))
        self.region_combobox = QComboBox()
        self.region_combobox.addItems(['Москва', 'Санкт-Петербург', 'Другой'])
        layout.addWidget(self.region_combobox)
        layout.addWidget(QLabel('Код МСУ'))
        self.msu_code_combobox = QComboBox()
        self.msu_code_combobox.addItems(['1', '2', '3'])
        layout.addWidget(self.msu_code_combobox)
        layout.addWidget(QLabel('Код ППЭ'))
        self.ppe_code_combobox = QComboBox()
        self.ppe_code_combobox.addItems(['1111', '2222', '3333'])
        layout.addWidget(self.ppe_code_combobox)
        layout.addWidget(QLabel('№ компьютера'))
        self.comp_number_combobox = QComboBox()
        self.comp_number_combobox.addItems(['11', '12', '13', '14', '15'])
        layout.addWidget(self.comp_number_combobox)
        self.correct_time_checkbox = QCheckBox('Системное время установлено корректно')
        layout.addWidget(self.correct_time_checkbox)
        self.correct_time_checkbox.stateChanged.connect(self.change_correct_system_time_checkbox)
        self.save_button = QPushButton('Сохранить')
        self.change_correct_system_time_checkbox()
        layout.addWidget(self.save_button)

        layout.setAlignment(Qt.AlignCenter)
        self.setObjectName('base_settings_widget')
